package com.rightsidetech.http.controller.storeApp;

import com.aliyun.oss.OSS;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.commom.config.AliyunOSSConfig;
import com.rightsidetech.commom.utils.UplodeUtils;
import com.rightsidetech.http.aspect.Auth;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.http.aspect.Token;
import com.rightsidetech.http.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/storeApp/file")
@ShenyuSpringMvcClient(path = "/storeApp/file/**")
@Api(tags = "文件上传")
public class StoreAppOSSController extends BaseController {

    @Autowired
    private OSS ossClient;

    @Autowired
    private AliyunOSSConfig aliyunOSSConfig;

    @Log
    @Token
    @PostMapping("/more_uplode")
    @ApiOperation("批量上传")
    public ResponseData<String[]> moreUplode(MultipartFile[] files) throws Exception {
        if (null == files || files.length == 0) {
            return ResponseData.fail("文件不能为空");
        }

        return UplodeUtils.adminMoreUplode(files,ossClient, aliyunOSSConfig);
    }
}
